:: This script requires WinRAR. 
:: If ..\WinRAR\rar.exe it will be used. 
:: Otherwise, it must be on the path.

@echo off

goto .%1

:.
    call %0 all hop comments
    goto :eof


:.all
    setlocal
    set path=%~dp0..\WinRAR;%path%
    shift
    del %1.rar
    del %1.exe
    call :.a %1
    call :.b %1
    call :.c %1 %2
    endlocal
    move %1.exe ..
    move %1.rar ..
    pause
    goto :eof

:.a
    :: make .rar 
    if "%1"==""               (echo arg required     & goto :eof)
    if exist %1.rar           (echo already done     & goto :eof)
    if not exist %1\root\nul  (echo source not found & goto :eof)
    rar a -r -ep1 %1 %1\root\*.*
    goto :eof

:.b
    :: make .exe
    if not exist %1.rar (echo missing rar & goto :eof)
    if     exist %1.exe (echo already done & goto :eof)
    rar s %1
    goto :eof

 
:.c
    :: add comments
    if not exist %1.exe    (echo exe not found       & goto :eof)
    if not exist %1\%2.txt (echo comments not found: "%2"  & goto :eof)
    rar c -z%1\%2.txt   %1.exe
    %1.exe
    goto :eof

